Total Complexity | 2 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import {Inject} from '@nestjs/common'; |
||
7 | |||
8 | @QueryHandler(GetTaskByIdQuery) |
||
9 | export class GetTaskByIdQueryHandler { |
||
10 | constructor( |
||
11 | @Inject('ITaskRepository') |
||
12 | private readonly taskRepository: ITaskRepository |
||
13 | ) {} |
||
14 | |||
15 | public async execute(query: GetTaskByIdQuery): Promise<TaskView> { |
||
16 | const task = await this.taskRepository.findOneById(query.id); |
||
17 | if (!task) { |
||
18 | throw new TaskNotFoundException(); |
||
19 | } |
||
20 | |||
21 | return new TaskView(task.getId(), task.getName()); |
||
22 | } |
||
24 |